from pydantic import BaseModel, Field
from typing import Optional, List, Any, Generic, TypeVar
from datetime import datetime

T = TypeVar('T')

class BaseSchema(BaseModel):
    """基础模式类"""
    id: Optional[int] = None
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None

class ResponseBase(BaseModel, Generic[T]):
    """基础响应模式"""
    code: int = Field(default=200, description="状态码")
    message: str = Field(default="操作成功", description="提示信息")
    data: Optional[T] = Field(default=None, description="响应数据")

class PageInfo(BaseModel):
    """分页信息"""
    page: int = Field(default=1, description="当前页码")
    page_size: int = Field(default=10, description="每页条数")
    total: int = Field(default=0, description="总条数")

class PageResponseBase(ResponseBase[T]):
    """分页响应模式"""
    page_info: Optional[PageInfo] = Field(default=None, description="分页信息")